package fzdy.core.common;

/**
 * Created by Administrator on 2017/3/27 0027.
 */
import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonTool {
    protected static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    protected static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public CommonTool() {
    }

    public static String nowDate() {
        return simpleDateFormat.format(new Date());
    }

    public static String stringDateTime(Long time) {
        return time == null?"":simpleDateTimeFormat.format(new Date(time.longValue()));
    }

    public static String stringDate(Long time) {
        return time == null?"":simpleDateFormat.format(new Date(time.longValue()));
    }

    public static Float compute(Float brokerage, Float scale) {
        if(brokerage != null && scale != null) {
            float v = brokerage.floatValue() * scale.floatValue() * 100.0F;
            float price = Float.parseFloat(String.valueOf(Math.floor((double)v) / 100.0D));
            return Float.valueOf(price > 0.0F?price:0.0F);
        } else {
            return Float.valueOf(0.0F);
        }
    }
}
